uniform sampler2D common;
uniform sampler2D lenticel;
uniform sampler2D split;
uniform sampler2D bark_info;
uniform sampler2D normals;
varying vec3 ptol;
void main(){
    vec4 info = texture2D(bark_info, gl_TexCoord[0].st);
    vec4 normal = texture2D(normals, gl_TexCoord[0].st);
    normal *= 2.0;
    normal = normal - vec4(1.0, 1.0, 1.0, 1.0);
    float intensity = max(0.0, dot(normalize(ptol), normalize(normal.xyz)));

    vec4 color;
    if (info.r > info.g && info.r > info.b){
        color = texture2D(common, gl_TexCoord[0].st);
    }
    else if (info.g > info.r && info.g > info.b){
        color = texture2D(lenticel, gl_TexCoord[0].st);
    }
    else if (info.b > info.r && info.b > info.g){
        color = texture2D(split, gl_TexCoord[0].st);
    }
    vec4 final_color = vec4(color.x*1.5, color.y*1.5, color.z, 1.0);
      // vec4 final_color = vec4(color.x, color.y, color.z, 1.0);
    gl_FragColor = vec4(final_color.xyz*intensity, 1.0);
    //gl_FragColor = vec4(info.xyz, 1.0);
    //gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);

}
